<?php include("/includes/header.php") ?>
<?php include("/includes/sidebar.php") ?>

<STYLE TYPE="text/css">
	.border {
		border: 1px solid #CCC;
	}
	.border-bottom {
		border-bottom: 1px dashed #DDD;
	}
	.invoice .border-bottom:last-child {
		border: none;
	}
	.invoice_no_placer, action_placer {
		text-align: center;
	}
	.display-table > div {
		height: inherit;
		width: inherit;
	}
</STYLE>

<div class="header">
	<span>
		<a href="resto.php">
			<i class="fa fa-cutlery"></i> Restaurant
		</a>
	</span>
	<span>
		<a href="resto-invoice-list.php">
			<i class="fa fa-list-alt"></i> Invoice List
		</a>
	</span>
</div>

<div class="content row-fluid">
	<div class="span12 table-placer">
		<div class="alert alert-info"><h4>Invoice List</h4></div>
		<div class="row-fluid index-pos-placer">
			<?php  
				$sql_tanggal = "SELECT DISTINCT(resto.tanggal) AS tanggal 
												FROM resto 
													INNER JOIN nota ON nota.idresto = resto.id 
												WHERE nota.is_paid = 1 AND payment = 1 
												ORDER BY tanggal";
				$query_tanggal = mysql_query($sql_tanggal);
				while ($tanggal = mysql_fetch_array($query_tanggal)) {
			?>
					<div class="alert"><?php echo $tanggal[tanggal]; ?></div>
					<div class="row-fluid span12" style="margin-left: 0; float: none;">
			<?php
					$sql_nota = "SELECT nota.* 
											FROM nota 
												INNER JOIN resto ON nota.idresto = resto.id 
											WHERE nota.is_paid = 1 AND nota.payment = 1 AND resto.tanggal = '$tanggal[tanggal]'";
					$query_nota = mysql_query($sql_nota);
					$i = 1;
					while ($nota = mysql_fetch_array($query_nota)) {
			?>
						<div class="invoice border" data-idnota="<?php echo $nota[id] ?>">
							<div class="span1 invoice_no_placer display-table">
								<div class="invoice_no">
									No. <?php echo $nota[id]; ?>
								</div>
							</div>
							<div class="span10 ">
			<?php
						$sql_resto_menu = "SELECT * FROM resto_menu WHERE idresto = '$nota[idresto]' AND bill = '$nota[bill]'";
						$query_resto_menu = mysql_query($sql_resto_menu);
						while ($resto_menu = mysql_fetch_array($query_resto_menu)) {
							$sql_menu = "SELECT * FROM menu WHERE id = '$resto_menu[idmenu]'";
							$query_menu = mysql_query($sql_menu);
							$menu = mysql_fetch_array($query_menu);
			?>
							<div class="border-bottom">
								<div class="span6" style="padding: 3px 10px"><?php echo $menu[nama] ?></div>
								<div class="span1" style="padding: 3px; text-align: center;"><?php echo $resto_menu[jumlah] ?></div>
								<div class="span2 currency" style="padding: 3px; text-align: right;"><?php echo $resto_menu[harga] ?></div>
								<div class="span2 currency" style="padding: 3px; text-align: right;"><?php echo $resto_menu[harga] * $resto_menu[jumlah] ?></div>
								<div class="clear"></div>
							</div>
			<?php
						}
			?>			
							</div>
							<div class="span1 action_placer display-table">
								<div class="action">
									Action
								</div>
							</div>
							<div class="clear"></div>
						</div>
			<?php
					}
			?>
					</div>
			<?php
				}
			?>
			
		</div>
	</div>
</div>

<div class="footer">
</div>

<?php include("/includes/footer.php") ?>

<script type="text/javascript">
	$(document).ready(function() {
		$('.invoice').each(function(index, el) {
			var height = $(this).height();

			$(this).find('.invoice_no_placer').css('height', height);
			$(this).find('.action_placer').css('height', height);
		});

		$('currency').autoNumeric('init', {
			aSign: 'IDR ',
			aPad: false
		});
	});
</script>
